<?php
function ListMenuLeftTourType()
{
global $id,$language,$dbsql,$module;
	//-----------------------------------------------------
	$sql_select = "select cName,iId from tbltourtype where cLanguage='$language' order by iOrder asc";
	$rs=$dbsql->query($sql_select);
    $return     = '';
	while($result = $dbsql->fetch_array($rs))
	{
		$return .="<div  style='padding-left:5px;' ";
        if($id==$result['iId'])
        {
            $return.=' class="selected" ';
        }
		$return.="><a  href='?module=".$module."&id=".$result["iId"]."'>";
		$return.="&raquo;".$result["cName"]."</a></div>";
	}
	return $return;
}

function ListTourTypeOption($select)
{
    global $dbsql,$language;

    $sql_select = "select cName,iId from tbltourtype where cLanguage='$language' order by iOrder asc";
	$rs         = $dbsql->query($sql_select);
    $options    = '';
	while($result = $dbsql->fetch_array($rs))
	{
	   if($select==$result['iId'])
       {
            $options .= '<option value="'.$result['iId'].'" selected>'.$result['cName'].'</option>';
       }else
       {
            $options .= '<option value="'.$result['iId'].'">'.$result['cName'].'</option>';
       }
	}
	return $options;
}

function InsertTourType($urlstring,$name,$description,$intro,$metatitle,$metadescription,$metakeywords,
                    $ImgIntro,$ImgBanner,$Status,$order,$IsEx)
{
    global $dbsql,$language,$postdate;
    $poster     = getUserNamePost();
    $sql_insert = "insert into tbltourtype
                    (cUrlString,cName,cDescription,cIntro,cMetaTitle,cMetaDescription,cMetaKeywords,
                    cImage,cBanner,iStatus,iOrder,dPostDate,cPoster,cLanguage,iIsEx)
                values('$urlstring','$name','$description','$intro','$metatitle','$metadescription','$metakeywords',
                    '$ImgIntro','$ImgBanner','$Status','$order','$postdate','$poster','$language','$IsEx')";
    return $dbsql->query($sql_insert);
}

function UpdateTourType($urlstring,$name,$description,$Intro,$metatitle,$metadescription,$metakeywords,
                    $ImgIntro,$ImgBanner,$Status,$order,$IsEx)
{
    global $dbsql,$language,$id;

    $sql_update = "update tbltourtype set ";
    $sql_update.= "cUrlString       = '$urlstring',";
    $sql_update.= "cName            = '$name',";
    $sql_update.= "cDescription     = '$description',";
    $sql_update.= "cIntro           = '$Intro',";
    $sql_update.= "cMetaTitle       = '$metatitle',";
    $sql_update.= "cMetaDescription = '$metadescription',";
    $sql_update.= "cMetaKeywords    = '$metakeywords',";
    $sql_update.= "cImage           = '$ImgIntro',";
    $sql_update.= "cBanner          = '$ImgBanner',";
    if($order>0)
    {
        $sql_update.= "iOrder       = '$order',";
    }
    $sql_update.= "iStatus          = '$Status',";
    $sql_update.= "iIsEx            = '$IsEx'";
    $sql_update.= " where iId       = $id";

    return $dbsql->query($sql_update);
}

function hasTour($idP)
{
    global $dbsql,$language;

    $sql_select="select iId from tblsettour where iParentId=$idP";
    $rs=$dbsql->query($sql_select);
    if($dbsql->num_rows($rs)>0)
    {
        return true;
    }else
    {
        return false;
    }
}
?>